<?php

/* * 注意此文档为UTF-8的编码.
 * Created on 2010-6-27
 *
 * @author EXT <isrn@qq.com>
 *
 */
include ('../../includes/global.php');
include ('../global.php');
include ("../power.php");
//require_once './render.php';
//require_once './items_config.php';
$dbcfg = Sys::Gp(array('dbcfg', 'sevenel'));
$donotrender = array('htmleditor', 'fckeditor', 'password', 'hidden');
switch ($_REQUEST['op']) {
    /**
     * 获取可排序字段
     * return json
     */
    case 'getOrderField':
        $orderField = Dgs('fld', "del!=1 and tid='{$_GET['tid']}' order by px");
        die(json_encode(array('data' => $orderField)));
        break;
    /**
     * 高级搜索在里面，不知道除了高级搜索还有没有其他的功能在里面 ^_^!
     * comment by Zuolong 2011-11-08
     */
    case 'list': {
            if ($_SESSION[userinfo][rcfg] == 4) {
                $cab = "and fname!='tj2' and fname!='tj3'";
            } else {
                $cab = '';
            }
            $fldata = Dgd(array(
                'db' => 'd_sevenel',
                'cd' => "tid = '" . $_GET['tid'] . "'" . $cab . " and del!=1 order by px asc ",
                'tn' => "fld"
                    ));
            Tr($fldata, 'fld');
            Tr($_GET['bdtid'], 'bdtid');
            Tr($_GET['bdid'], 'bdid');
            foreach ($fldata as $key => $v) {
                if ($v['xr'] == 0) {
                    $xr[] = $v;
                }
                if ($v['gj'] == 1) {
                    $gj[] = $v;
                }
            }
            Tr($xr, 'xr');
            if ($gj != '') {
                foreach ($gj as $key => $value) {
                    if ($value['cfg'] != '') {
                        $config = json_decode($value['cfg'], true);
                    } else {
                        $config = '';
                    }
                    $config['STR'] = str_replace("\r", "", $config['STR']);
                    $config['STR'] = str_replace("\n", "", $config['STR']);
                    $config['STR'] = str_replace("\t", "", $config['STR']);
                    switch ($value['type']) {
                        case 'datefield': {
                                $js[] = "{
							xtype: 'datefield',
							value:\"\",
							fieldLabel:'" . $value['name'] . "',
							" . (($value['id']) ? ("id:'" . $value['id'] . "',") : ("")) . "
							" . (($config['STR']) ? ("" . $config['STR'] . "") : ("")) . "
							" . (($config['zqgs']) ? ("format:'" . $config['zqgs'] . "',") : ("")) . "
							name: '" . $value['fname'] . "'
							}";
                                break;
                            }
                        case 'my97': {
                                $js[] = "
                                    {
                                        layout:'column',
                                        items:[{

                                            columnWidth : .4,
                                            layout : 'form',
                                            items:[{
                                                xtype: 'textfield',
                                                value:'',
                                                fieldLabel:'{$value['name']}',
                                                cls:'Wdate',
                                                " . (($value['id']) ? ("id:'{$value['id']}',") : ("")) . "
                                                " . (($config['STR']) ? ("{$config['STR']}") : ("")) . "
                                                name: '{$value['fname']}_range',
                                                listeners:{
                                                    focus:function(){
                                                        WdatePicker({dateFmt:'{$config['mygs']}'});
                                                    }
                                                }
                                            }]
                                        },{
                                            columnWidth : .5,
                                            layout : 'form',
                                            items:[{
                                                xtype: 'textfield',
                                                value:'',
                                                fieldLabel:'至&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;',
                                                cls:'Wdate',
                                                " . (($value['id']) ? ("id:'{$value['id']}_range',") : ("")) . "
                                                " . (($config['STR']) ? ("{$config['STR']}") : ("")) . "
                                                name: '{$value['fname']}_range2',
                                                listeners:{
                                                    focus:function(){
                                                        WdatePicker({dateFmt:'{$config['mygs']}'});
                                                    }
                                                }
                                            }]
                                        }]
                                    }
                                    ";
                                break;
                            }
                        case 'combo': {
                                $tempxx = json_decode($value['zyz'], true);
                                $config_num = count($tempxx);
                                $items = '';
                                if ($config_num != 0) {
                                    foreach ($tempxx as $key => $data) {
                                        if ($data['ck'] == '1') {
                                            $xzz = $data['xv'];
                                        }
                                        $items.= "['" . $data['xv'] . "','" . $data['yv'] . "']";
                                        if ($key < $config_num - 1) {
                                            $items.= ",";
                                        }
                                    }
                                }
                                $js[] = "{
							value:\"\",
							fieldLabel:'" . $value['name'] . "',
							" . (($value['id']) ? ("id:'" . $value['id'] . "',") : ("")) . "
							" . (($value['width']) ? ("width:" . $value['width'] . ",") : ("")) . "
							" . (($config['readonly']) ? ("readOnly:'true',") : ("")) . "
							typeAhead: true,
							name: '" . $value['fname'] . "_',
							hiddenName : '" . $value['fname'] . "',
							editable: false,xtype: 'combo',
							store:new Ext.data.SimpleStore({
											fields:['name','value'],
											data:[" . $items . "]}),
							mode:'local',
					        displayField:'name',
					        selectOnFocus:true,
					        valueField :'value',
					        triggerAction:'all'

							}";
                                break;
                            }
                        case 'combo1': {

                                $js[] = "{
							" . $back . "
							value:\"" . (adxx($fdada[$value['fname']]) ? adxx($fdada[$value['fname']]) : $config['dy']) . "\",
							fieldLabel:'" . $value['name'] . "',
							" . (($value['id']) ? ("id:'" . $value['id'] . "',") : ("")) . "
							" . (($value['width']) ? ("width:" . $value['width'] . ",") : ("")) . "
							" . ((!$value['yxwk']) ? ("allowBlank:false,blankText:'" . adxx($value['ts']) . "',") : ("")) . "
							" . (($config['readonly']) ? ("readOnly:'true',") : ("")) . "
							typeAhead: true,
							emptyText:'" . $config['dx'] . "',
							name: '" . $value['fname'] . "_',
							id: '" . $value['fname'] . "_',
							hiddenName : '" . $value['fname'] . "',
							editable: false,xtype: 'combo',
							store:new Ext.data.Store({
								proxy: new Ext.data.HttpProxy({
									url: '../cascade/getcascade.php?id=" . $value['id'] . "'
								}),
								listeners : {
								load : function(){

										if(typeof(chuzai)=='undefined'){
											Ext.getCmp('" . $value['fname'] . "_" . "').setValue('" . (adxx($fdada[$value['fname']]) ? adxx($fdada[$value['fname']]) : $config['dy']) . "');
											chuzai=1;
											}
										}
										} ,
								autoLoad:true,
								reader: new Ext.data.ArrayReader({
							}, [
								{name: '" . $config['y'] . "', mapping: '" . $config['y'] . "'},
								{name: '" . $config['x'] . "', mapping: '" . $config['x'] . "'}
							])
}),
							mode:'local',
					        displayField:'" . $config['x'] . "',
					        selectOnFocus:true,
					        valueField :'" . $config['y'] . "',
							" . (($config['STR']) ? ("" . $config['STR'] . "") : ("")) . "
					        triggerAction:'all'

							}";
                                break;
                            }
                        case 'combo2': {

                                $js[] = "{
							" . $back . "
							value:\"" . (adxx($fdada[$value['fname']]) ? adxx($fdada[$value['fname']]) : $config['dy']) . "\",
							fieldLabel:'" . $value['name'] . "',
							" . (($value['id']) ? ("id:'" . $value['id'] . "',") : ("")) . "
							" . (($value['width']) ? ("width:" . $value['width'] . ",") : ("")) . "
							" . ((!$value['yxwk']) ? ("allowBlank:false,blankText:'" . adxx($value['ts']) . "',") : ("")) . "
							" . (($config['readonly']) ? ("readOnly:'true',") : ("")) . "
							typeAhead: true,
							" . (($value['zy']) ? ("emptyText:'" . $config['x2'] . "',") : ("emptyText:'" . $config['x1'] . "',")) . "
							name: '" . $value['fname'] . "_',
							id: '" . $value['fname'] . "_',
							hiddenName : '" . $value['fname'] . "',
							editable: false,xtype: 'combo',
							store:new Ext.data.Store({
								proxy: new Ext.data.HttpProxy({
									url: '" . (($config['zy']) ? (($fdada[$config['jlzd']]) ? ("../cascade/getcascade.php?op=sort&id=" . $fdada[$config['jlzd']] . "") : ("")) : ("../cascade/getcascade.php?op=sort&id=" . $config['pid'] . "")) . "'
								}),
								listeners : {
								load : function(){
							" . (($config['zy']) ? ("if(typeof(chuzai1)=='undefined'){
											Ext.getCmp('" . $value['fname'] . "_" . "').setValue('" . (adxx($fdada[$value['fname']]) ? adxx($fdada[$value['fname']]) : $config['y2']) . "');
											chuzai1=1;
											}
										} ") : ("if(typeof(chuzai)=='undefined'){
											Ext.getCmp('" . $value['fname'] . "_" . "').setValue('" . (adxx($fdada[$value['fname']]) ? adxx($fdada[$value['fname']]) : $config['y1']) . "');
											chuzai=1;
											}
										} ")) . "

										} ,
								autoLoad:true,
								reader: new Ext.data.ArrayReader({
							}, [
								{name: 'id', mapping: 'id'},
								{name: 'title', mapping: 'title'}
							])
}),
							mode:'local',
					        displayField:'title',
					        selectOnFocus:true,
					        valueField :'id',
							" . (($config['STR']) ? ("" . $config['STR'] . "") : ("")) . "
					        triggerAction:'all'
							" . (($config['zy']) ? ("") : (",
							listeners:{
								select : function(combo, record,index){
								Ext.getCmp('" . $config['jlzd'] . "_" . "').store.proxy= new Ext.data.HttpProxy({url: '../cascade/getcascade.php?op=sort&id=' + combo.value});   								Ext.getCmp('" . $config['jlzd'] . "_" . "').store.load();			Ext.getCmp('" . $config['jlzd'] . "_" . "').setValue('');

								}
								}")) . "


							}";

                                break;
                            }
                        case 'combo3': {
                                $url = '';
                                $chuzai = '';
                                $select = '';
                                switch ($config['jb']) {
                                    case 1: {
                                            $url = "../cascade/getcascade.php?op=sort&id=" . $config['pid'];
                                            $chuzai = "if(typeof(chuzai1)=='undefined'){
											Ext.getCmp('" . $value['fname'] . "_" . "').setValue('" . (adxx($fdada[$value['fname']]) ? adxx($fdada[$value['fname']]) : $config['y']) . "');
											chuzai1=1;
											}";
                                            $select = " Ext.getCmp('" . $config['jl1'] . "_" . "').store.proxy= new Ext.data.HttpProxy({url: '../cascade/getcascade.php?op=sort&id='+combo.value}); Ext.getCmp('" . $config['jl1'] . "_" . "').store.load();
									 Ext.getCmp('" . $config['jl2'] . "_" . "').store.proxy= new Ext.data.HttpProxy({url: '../cascade/getcascade.php?op=kong'}); Ext.getCmp('" . $config['jl2'] . "_" . "').store.load();
								Ext.getCmp('" . $config['jl1'] . "_" . "').setValue('');
								Ext.getCmp('" . $config['jl2'] . "_" . "').setValue(''); ";
                                            break;
                                        }
                                    case 2: {
                                            $url = $fdada[$config['jl1']] ? "../cascade/getcascade.php?op=sort&id=" . $fdada[$config['jl1']] : "";
                                            $chuzai = "if(typeof(chuzai2)=='undefined'){
											Ext.getCmp('" . $value['fname'] . "_" . "').setValue('" . (adxx($fdada[$value['fname']]) ? adxx($fdada[$value['fname']]) : $config['y']) . "');
											chuzai2=1;
											}";
                                            $select = " Ext.getCmp('" . $config['jl2'] . "_" . "').store.proxy= new Ext.data.HttpProxy({url: '../cascade/getcascade.php?op=sort&id=' + combo.value}); Ext.getCmp('" . $config['jl2'] . "_" . "').store.load();
								Ext.getCmp('" . $config['jl2'] . "_" . "').setValue('');";
                                            break;
                                        }
                                    case 3: {
                                            $url = $fdada[$config['jl2']] ? "../cascade/getcascade.php?op=sort&id=" . $fdada[$config['jl2']] : "";
                                            $chuzai = "if(typeof(chuzai3)=='undefined'){
											Ext.getCmp('" . $value['fname'] . "_" . "').setValue('" . (adxx($fdada[$value['fname']]) ? adxx($fdada[$value['fname']]) : $config['y']) . "');
											chuzai3=1;
											}";
                                            break;
                                        }
                                }
                                $js[] = "{
							" . $back . "
							value:\"" . (adxx($fdada[$value['fname']]) ? adxx($fdada[$value['fname']]) : $config['y']) . "\",
							fieldLabel:'" . $value['name'] . "',
							" . (($value['id']) ? ("id:'" . $value['id'] . "',") : ("")) . "
							" . (($value['width']) ? ("width:" . $value['width'] . ",") : ("")) . "
							" . ((!$value['yxwk']) ? ("allowBlank:false,blankText:'" . adxx($value['ts']) . "',") : ("")) . "
							" . (($config['readonly']) ? ("readOnly:'true',") : ("")) . "
							typeAhead: true,
							emptyText:'" . $config['x'] . "',
							name: '" . $value['fname'] . "_',
							id: '" . $value['fname'] . "_',
							hiddenName : '" . $value['fname'] . "',
							editable: false,xtype: 'combo',
							store:new Ext.data.Store({
								proxy: new Ext.data.HttpProxy({
									url: '" . $url . "'
								}),
								listeners : {
								load : function(){
								" . $chuzai . "
								}} ,
								autoLoad:true,
								reader: new Ext.data.ArrayReader({
							}, [
								{name: 'id', mapping: 'id'},
								{name: 'title', mapping: 'title'}
							])
}),
							mode:'local',
					        displayField:'title',
					        selectOnFocus:true,
					        valueField :'id',
							" . (($config['STR']) ? ("" . $config['STR'] . "") : ("")) . "
					        triggerAction:'all',
							listeners:{
								select : function(combo, record,index){" . $select . "}
								}
							}";
                                break;
                            }
                        case 'radiogroup': {
                                $tempxx = json_decode($value['zyz'], true);
                                $config_num = count($tempxx);
                                if ($config_num != 0) {
                                    $items = '';
                                    foreach ($tempxx as $key => $data) {
                                        if ($data['ck'] == '1') {
                                            $items.= "{boxLabel:'" . $data['xv'] . "',name:'" . $value['fname'] . "',inputValue:'" . $data['yv'] . "',checked: true}";
                                        } else {
                                            $items.= "{boxLabel:'" . $data['xv'] . "',name:'" . $value['fname'] . "',inputValue:'" . $data['yv'] . "'}";
                                        }
                                        if ($key < $config_num - 1) {
                                            $items.= ",";
                                        }
                                    }
                                }
                                $js[] = "{
							xtype: 'radiogroup',
							" . (($value['width'] && $value['width'] <= $config_num) ? ("columns:" . $value['width'] . ",") : ("")) . "
							" . (($config['vertical']) ? ("vertical: true,") : ("")) . "
							anchor: '95%',
							 items: [" . $items . "],
							fieldLabel:'" . $value['name'] . "'
							}";
                                break;
                            }
                        case 'recommend': {
                                $items = '';
                                $items.= "{boxLabel:'全部',name:'" . $value['fname'] . "',inputValue:'',checked: true},";
                                $items.= "{boxLabel:'推荐中',name:'" . $value['fname'] . "',inputValue:'1'},";
                                $items.= "{boxLabel:'不推荐',name:'" . $value['fname'] . "',inputValue:'0'}";

                                $js[] = "{
							xtype: 'radiogroup',
							anchor: '95%',
							 items: [" . $items . "],
							fieldLabel:'" . $value['name'] . "'
							}";
                                break;
                            }
                        case 'checkboxgroup': {
                                $tempxx = json_decode($value['zyz'], true);
                                $config_num = count($tempxx);
                                if ($config_num != 0) {
                                    $items = '';
                                    foreach ($tempxx as $key => $data) {
                                        $ckbox[] = $value['fname'] . "[" . $key . "]";
                                        if ($data['ck'] == '1') {
                                            $items.= "{boxLabel:'" . $data['xv'] . "',name:'" . $value['fname'] . "[" . $key . "]',inputValue:'" . $data['yv'] . "',checked: true}";
                                        } else {
                                            $items.= "{boxLabel:'" . $data['xv'] . "',name:'" . $value['fname'] . "[" . $key . "]',inputValue:'" . $data['yv'] . "'}";
                                        }
                                        if ($key < $config_num - 1) {
                                            $items.= ",";
                                        }
                                    }
                                }
                                $js[] = "{
							xtype:'checkboxgroup',
							" . (($value['width'] && $value['width'] <= $config_num) ? ("columns:" . $value['width'] . ",") : ("")) . "
							" . (($config['vertical']) ? ("vertical: true,") : ("")) . "
							anchor: '95%',
							 items: [" . $items . "],
							fieldLabel:'" . $value['name'] . "'
							}";
                                break;
                            }
                        case 'checkboxgroup1': {
                                $tempxx = Dgs("{$config['table']}", "{$config['conditon']}");
                                $config_num = count($tempxx);
                                if ($config_num != 0) {
                                    $items = '';
                                    foreach ($tempxx as $key => $data) {
                                        $ckbox[] = $value['fname'] . "[" . $key . "]";
                                        if ($data['ck'] == '1') {
                                            $items.= "{boxLabel:'" . $data[$config['x']] . "',name:'" . $value['fname'] . "[" . $key . "]',inputValue:'" . $data[$config['y']] . "',checked: true}";
                                        } else {
                                            $items.= "{boxLabel:'" . $data[$config['x']] . "',name:'" . $value['fname'] . "[" . $key . "]',inputValue:'" . $data[$config['y']] . "'}";
                                        }
                                        if ($key < $config_num - 1) {
                                            $items.= ",";
                                        }
                                    }
                                }
                                $js[] = "{
					xtype:'checkboxgroup',
					" . (($value['width'] && $value['width'] <= $config_num) ? ("columns:" . $value['width'] . ",") : ("")) . "
					" . (($config['vertical']) ? ("vertical: true,") : ("")) . "
					anchor: '95%',
					items: [" . $items . "],
					fieldLabel:'" . $value['name'] . "'
				}";
                                break;
                            }
                        default: {

                                //区间搜索
                                if ($config['qj']) {

                                    $js[] = "
                                    {
                                        layout:'column',
                                        items:[{

                                            columnWidth : .4,
                                            layout : 'form',
                                            items:[{
                                                xtype: 'textfield',
                                                value:'',
                                                fieldLabel:'{$value['name']}',
                                                " . (($value['id']) ? ("id:'{$value['id']}',") : ("")) . "
                                                " . (($config['STR']) ? ("{$config['STR']}") : ("")) . "
                                                name: '{$value['fname']}_range'
                                            }]
                                        },{
                                            columnWidth : .5,
                                            layout : 'form',
                                            items:[{
                                                xtype: 'textfield',
                                                value:'',
                                                fieldLabel:'至&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;',
                                                " . (($value['id']) ? ("id:'{$value['id']}_range',") : ("")) . "
                                                " . (($config['STR']) ? ("{$config['STR']}") : ("")) . "
                                                name: '{$value['fname']}_range2'
                                            }]
                                        }]
                                    }
                                    ";
                                } else {
                                    $js[] = "{
                                    xtype: 'textfield',
                                    value:\"\",
                                    fieldLabel:'" . $value['name'] . "',
                                    " . (($value['id']) ? ("id:'" . $value['id'] . "',") : ("")) . "
                                    " . (($value['width']) ? ("width:'" . $value['width'] . "px',") : ("grow:true,growMin:68,growMax:300,")) . "
                                    " . (($config['STR']) ? ("" . $config['STR'] . "") : ("")) . "
                                    name: '" . $value['fname'] . "'
                                    }";
                                }
                            }
                    }
                }
            }
            Tr($ckbox, 'ckbox');
            Tr($js, 'js');
            $tree = Dgd(array(
                'db' => 'd_sevenel',
                'cd' => "id = '" . $_GET['tid'] . "' ",
                'tn' => "tree",
                'limit' => 1
                    ));
            Tr($tree, 'tree');
            Tr(json_decode($tree['config'], true), 'tree_config');
            if ($tree['expand']) {
                $fstree = Dgd(array(
                    'db' => 'd_sevenel',
                    'cd' => "id in (0," . $tree['expand'] . ") ",
                    'tn' => "tree"
                        ));
            }
            $fsstr = '';
            if ($fstree) {
                foreach ($fstree as $fsvalue) {
                    $ttree = Dgd(array(
                        'db' => 'd_sevenel',
                        'cd' => "id = " . $fsvalue['id'] . "",
                        'tn' => "tree",
                        'limit' => '1'
                            ));
                    $config_tmp = json_decode($ttree['config'], true);
                    if ($ttree['config'] != '' && $ttree['config'] != '{"lg":""}' && strpos($config_tmp['lg'], '|') !== false) {
                        $fsstr.=",
                            {
                                xtype:\"button\",
                                text:\"添加" . $fsvalue['title'] . "\",
                                iconCls:\"fsadd\",
                                pressed:true,handler:function(){
                                    var record = grid.getStore().getAt(rowIndex);
                                    fsadd('" . $fsvalue['id'] . "','" . $fsvalue['title'] . "',\"./dy/index.php?op=loaddata&tid=" . $fsvalue['id'] . "&bdtid=" . $_GET['tid'] . "&bdid=\",record.data.id);
                                }
                            },{
                                xtype:\"button\",
                                text:\"浏览" . $fsvalue['title'] . "\",
                                iconCls:\"fslist\",
                                pressed:true,
                                handler:function(){
                                    var record = grid.getStore().getAt(rowIndex);
                                    //fslist('" . $fsvalue['id'] . "','" . $fsvalue['title'] . "',\"./dy/index.php?tid=" . $fsvalue['id'] . "&bdtid=" . $_GET['tid'] . "&bdid=\",record.data.id);
                                    createTab('tab_{$fsvalue['id']}',record.data.title+'-{$fsvalue['title']}','./dy/index.php?tid={$fsvalue['id']}&bdtid={$_GET['tid']}&bdid='+record.data.id);
                                }
                            }";
                    } else {
                        $fsstr.=",
                            {
                                xtype:\"button\",
                                text:\"添加" . $fsvalue['title'] . "\",
                                iconCls:\"fsadd\",
                                pressed:true,
                                handler:function(){
                                    var record = grid.getStore().getAt(rowIndex);
                                    fsadd('" . $fsvalue['id'] . "','" . $fsvalue['title'] . "',\"./show1/i.php?op=add&tid=" . $fsvalue['id'] . "&bdtid=" . $_GET['tid'] . "&bdid=\",record.data.id);
                                }
                            },{
                                xtype:\"button\",
                                text:\"浏览" . $fsvalue['title'] . "\",
                                iconCls:\"fslist\",
                                pressed:true,
                                handler:function(){
                                    var record = grid.getStore().getAt(rowIndex);
                                    //fslist('" . $fsvalue['id'] . "','" . $fsvalue['title'] . "',\"./show1/l.php?op=list&tid=" . $fsvalue['id'] . "&bdtid=" . $_GET['tid'] . "&bdid=\",record.data.id);
                                    createTab('tab_{$fsvalue['id']}',record.data.title+'-{$fsvalue['title']}','./show1/l.php?op=list&tid={$fsvalue['id']}&bdtid={$_GET['tid']}&bdid='+record.data.id);
                                }
                            }";
                    }
                }
            }

            /**
             * 实时房价、房态
             */
            $config_tmp = json_decode($tree['config'], true);
            if (1 == $config_tmp['realtime_price'] || 1 == $config_tmp['realtime_room']) {
                $realtime_title = '实时';
                //跳转链接
                $realtime_url = "/gl/price/real_time.php?bdtid={$_GET['tid']}";
                $realtime_title_tmp = array();
                //显示哪种类型:价格及房态
                $realtime_type = '';
                if (1 == $config_tmp['realtime_price']) {
                    $realtime_title_tmp[] = '房价';
                    $realtime_type .= '&realtime_show_price=1';
                }
                if (1 == $config_tmp['realtime_room']) {
                    $realtime_title_tmp[] = '房态';
                    $realtime_type .= '&realtime_show_room=1';
                }
                $realtime_title .= implode('/', $realtime_title_tmp);
                $realtime_url .= $realtime_type;
                $fsstr .= <<<EQT
                        ,{
                        xtype:"button",
                        text:"{$realtime_title}",
                        iconCls:"real_time",
                        pressed:true,
                        handler:function(){
                            var record = grid.getStore().getAt(rowIndex);
                            createTab('tab_'+record.data.id,record.data.title+'-{$realtime_title}','{$realtime_url}&bdid='+record.data.id);
                            //fslist('{$fsvalue['id']}','{$realtime_title}',"./dy/index.php?tid={$fsvalue['id']}&bdtid={$_GET['tid']}&bdid=",record.data.id);
                        }
                    }
EQT;
            }

            Tr($fsstr, 'fstree');

            $table = Dgd(array(
                'db' => 'd_sevenel',
                'cd' => "id = '" . $tree['table'] . "' ",
                'tn' => "datamod",
                'limit' => 1
                    ));
            Tr($table, 'table');


            Ts('show1/list.html');

            break;
        }
    case 'fy': {

            if ($_REQUEST['tid'] == 63 && $_SESSION['userinfo']['user'] != 'admin') {
                $cfg_sb = " and user='{$_SESSION['userinfo']['user']}'";
            }
            $fldata = Dgd(array(
                'db' => 'd_sevenel',
                'cd' => "tid = '" . $_POST['tid'] . "' and del!=1 order by px asc ",
                'tn' => "fld"
                    ));
            $zhuanyi = array();
            $btsc = array();
            $gjsc = array();
            foreach ($fldata as $key => $value) {
                if ($value['zy'] == 1 || $value['type'] == 'my97' || $value['type'] == 'datefield') {
                    $zhuanyi[] = $value;
                }
                if ($value['bt'] == 1) {
                    $btsc[$value['fname']] = $value['type'];
                }
                if ($value['gj'] == 1) {
                    $gjsc[] = $value;
                }
                /*
                 * 下面的是用于关键字模糊搜索用
                 */
                if (($value['type'] == 'textfield' || $value['type'] == 'fckeditor') && ($_POST['title'] != '' && !is_array($_POST['title']))) {
                    $_search_array_tmp [] = " {$value['fname']} like '%{$_POST['title']}%'";
                }
            }
            //组合 关键字模糊搜索
            if ($_search_array_tmp != '') {
                $_search_array_tmp = ' and (' . join(' or ', $_search_array_tmp) . ') ';
            }

            //$_POST['title'] && $condition.="and title like '%" . $_POST['title'] . "%' ";
            $_POST['bdtid'] && $condition.="and bdtid = '" . $_POST['bdtid'] . "' ";
            $_POST['bdid'] && $condition.="and bdid = '" . $_POST['bdid'] . "' ";
            if ($gjsc) {
                $xzt = array('combo', 'combo1', 'recommend', 'radiogroup');
                foreach ($gjsc as $value) {
                    //字段配置
                    $config_cfg = json_decode($value['cfg'], true);
                    //单选、推荐、静态下拉
                    if (in_array($value['type'], $xzt)) {
                        $_POST[$value['fname']] != '' && $condition.="and " . $value['fname'] . " = '" . $_POST[$value['fname']] . "' ";
                    } else {
                        //多选
                        if ($value['type'] == 'checkboxgroup') {
                            if ($_POST[$value['fname']]) {
                                foreach ($_POST[$value['fname']] as $cv) {
                                    $cv != '' && $sql_dt[$ck] = "{$value['fname']} like '{$cv}' or {$value['fname']} like '{$cv}#%' or {$value['fname']} like '%#{$cv}' or {$value['fname']} like '%#{$cv}#%'";
                                }
                                if ($sql_dt) {
                                    $condition .= "and (";
                                    $condition .= implode(" or ", $sql_dt);
                                    $condition .= ") ";
                                }
                            }
                            //区间搜索
                        } else if ($value['type'] == 'checkboxgroup1') {    //动态多选
                            if ($_POST[$value['fname']]) {
                                foreach ($_POST[$value['fname']] as $ck => $cv) {
                                    $cv != '' && $sql_dtt[$ck] = "{$value['fname']} like '{$cv}' or {$value['fname']} like '{$cv}#%' or {$value['fname']} like '%#{$cv}' or {$value['fname']} like '%#{$cv}#%'";
                                }
                                if ($sql_dtt) {
                                    $condition .= "and (";
                                    $condition .= implode(" or ", $sql_dtt);
                                    $condition .= ") ";
                                }
                            }
                            //区间搜索
                        } else if ($config_cfg['qj'] == 1 || $value['type'] == 'my97') {
                            //区间开始
                            if ('' != $_POST["{$value['fname']}_range"]) {
                                $range_start = $_POST["{$value['fname']}_range"];
                                //将my97转换为时间戳
                                if ($value['type'] == 'my97' && $value['zy'] != 1) {
                                    $range_start = strtotime($_POST["{$value['fname']}_range"]);
                                }
                                $condition .= " and {$value['fname']}>='{$range_start}' ";
                            }
                            //区间结束
                            if ('' != $_POST["{$value['fname']}_range2"]) {
                                $range_end = $_POST["{$value['fname']}_range2"];
                                //将my97转换为时间戳
                                if ($value['type'] == 'my97' && $value['zy'] != 1) {
                                    $range_end = strtotime($_POST["{$value['fname']}_range2"]);
                                }
                                $condition .= " and {$value['fname']}<='{$range_end}' ";
                            }

                            //普通匹配
                        } else {
                            $_POST[$value['fname']] != '' && $condition.="and " . $value['fname'] . " like '%" . $_POST[$value['fname']] . "%' ";
                        }
                    }
                }
            }
			/*
            if ($_SESSION['userinfo']['rcfg'] == 4 && $_POST['tid'] == 206) {
                $condition2 = "and ubb1=" . $_SESSION['userinfo']['id'] . "";
            } else if ($_SESSION['userinfo']['rcfg'] == 1 || $_SESSION['userinfo']['rcfg'] == 3) {
                $condition2 = '';
            }*/

            /**
             * 排序
             */
            $order = 'order by id desc';
            if ($_POST['sort'] != '') {
                $order = "order by {$_POST['sort']} {$_POST['dir']}";
                if ($_POST['sort'] != 'id') {
                    $order .= ",id {$_POST['dir']}";
                }
            }

            /**
             * 增加Plugin 钩子
             */
            $plugin = Plugin::init();
            $plugin->trigger('show1_fy_getdata_pre', $save);

            $dbinfo = Dgd(array(
                'db' => 'd_sevenel',
                'tn' => $_POST['dbname'],
                'start' => $_POST['start'],
                'limit' => $_POST['limit'],
                'total' => true,
                //'ce'=>1,
                'cd' => " 1 and tid = '" . $_POST['tid'] . "' " . $condition . " and del != '1' " . $condition2 . "  {$cfg_sb} {$order} "
                    ));
            //统计
            //转换

            foreach ($dbinfo['data'] as $key => $value) {
                foreach ($zhuanyi as $zyv) {
                    //Jc($zyv['fname'].'-'.$zyv['type']);
                    switch ($zyv['type']) {
                        case 'datefield':
                        case 'my97': {
                                $config = json_decode($zyv['cfg'], true);
                                if ($dbinfo['data'][$key][$zyv['fname']] != '' && is_numeric($dbinfo['data'][$key][$zyv['fname']]) && $config['zqgs'] != '') {
                                    $dbinfo['data'][$key][$zyv['fname']] = date($config['zqgs'], $dbinfo['data'][$key][$zyv['fname']]);
                                }
                                break;
                            }
                        case 'fileup': {
                                //echo $dbinfo['data'][$key][$zyv['fname']];
                                $config = json_decode($zyv['cfg'], true);
                                //图片地址
                                $config['sclj'] || $config['sclj'] = 'pic';
                                $dvalue = array(0 => array('rar', 'zip', 'tar', '.tz'),
                                    1 => array('jpg', 'gif', 'png', 'bmp'),
                                    2 => array('mp3', 'mp4', 'avi', 'wmv', 'mid', '.rm', 'mvb', 'mov', 'wma', 'wav'),
                                    3 => array('doc', 'xls', 'txt', 'ocx', 'lsx', 'ppt', 'pdf', 'chm'),
                                    4 => array('doc', 'xls', 'txt', 'ocx', 'lsx', 'ppt', 'pdf', 'chm', 'mp3', 'mp4', 'avi', 'wmv', 'mid', '.rm', 'mvb', 'mov', 'wma', 'wav', 'jpg', 'gif', 'png', 'bmp', 'rar', 'zip', 'tar', '.tz')
                                );
                                $otype = substr(strtolower($dbinfo['data'][$key][$zyv['fname']]), -3);
                                if (in_array($otype, $dvalue[0])) {
                                    $dbinfo['data'][$key][$zyv['fname']] = "<a href=\"/uplods/{$config['sclj']}/" . $dbinfo['data'][$key][$zyv['fname']] . "\" target='_blank'><img src=\"../img/archive.png\">下载[Download]</a>";
                                }
                                if (in_array($otype, $dvalue[1])) {
                                    if ($config['sl1'] == 1) {
                                        $dbinfo['data'][$key][$zyv['fname']] = "<img src=\"/uplods/thumb1/" . $dbinfo['data'][$key][$zyv['fname']] . "\" >";
                                    } elseif ($config['sl2'] == 1) {
                                        $dbinfo['data'][$key][$zyv['fname']] = "<img src=\"/uplods/thumb2/" . $dbinfo['data'][$key][$zyv['fname']] . "\" >";
                                    } elseif ($config['sypic'] == 1 || $config['sytxt'] == 1) {
                                        $dbinfo['data'][$key][$zyv['fname']] = "<img src=\"/uplods/sytp/" . $dbinfo['data'][$key][$zyv['fname']] . "\"  width=\"100px\">";
                                    } else {
                                        $dbinfo['data'][$key][$zyv['fname']] = "<img src=\"/uplods/{$config['sclj']}/" . $dbinfo['data'][$key][$zyv['fname']] . "\"  width=\"100px\">";
                                    }
                                }
                                if (in_array($otype, $dvalue[2])) {
                                    $dbinfo['data'][$key][$zyv['fname']] = "<a href=\"/uplods/{$config['sclj']}/" . $dbinfo['data'][$key][$zyv['fname']] . "\" target='_blank'><img src=\"../img/film_link.png\">下载[Download]</a>";
                                }
                                if (in_array($otype, $dvalue[3])) {
                                    $dbinfo['data'][$key][$zyv['fname']] = "<a href=\"/uplods/{$config['sclj']}/" . $dbinfo['data'][$key][$zyv['fname']] . "\" target='_blank'><img src=\"../img/report_word.png\">下载[Download]</a>";
                                }
                                break;
                            }
                        case 'radiogroup': {
                                $tempxx = json_decode($zyv['zyz'], true);
                                foreach ($tempxx as $value) {
                                    if ($value['yv'] == $dbinfo['data'][$key][$zyv['fname']]) {
                                        $dbinfo['data'][$key][$zyv['fname']] = $value['xv'];
                                    }
                                }
                                break;
                            }
                        case 'checkboxgroup': {
                                $tempxx = json_decode($zyv['zyz'], true);
                                $nowv = explode('#_#', $dbinfo['data'][$key][$zyv['fname']]);
                                $dbinfo['data'][$key][$zyv['fname']] = '';
                                foreach ($tempxx as $value) {
                                    if (in_array($value['yv'], $nowv)) {
                                        $dbinfo['data'][$key][$zyv['fname']].=$value['xv'] . "<BR>";
                                    }
                                }
                                break;
                            }
                        case 'checkboxgroup1': {
                                $config = json_decode($zyv['cfg'], true);
                                if ($dbinfo['data'][$key][$zyv['fname']] != '') {
                                    $nowv = "'" . str_replace("#_#", "','", $dbinfo['data'][$key][$zyv['fname']]) . "'";
                                    if ($nowv) {
                                        $result = Dz("SELECT `{$config['x']}` FROM `se_{$config['table']}` WHERE `{$config['y']}` in ({$nowv}) AND {$config['conditon']}");
                                        foreach ($result as $v) {
                                            $temp[] = $v[$config['x']];
                                        }
                                        $dbinfo['data'][$key][$zyv['fname']] = implode(",", $temp);
                                    }
                                    unset($nowv, $result, $temp);
                                }
                                break;
                            }
                        case 'combo': {
                                $tempxx = json_decode($zyv['zyz'], true);
                                foreach ($tempxx as $value) {
                                    if ($value['yv'] == $dbinfo['data'][$key][$zyv['fname']]) {
                                        $dbinfo['data'][$key][$zyv['fname']] = $value['xv'];
                                    }
                                }
                                break;
                            }
                        case 'combo1': {
                                $config = json_decode($zyv['cfg'], true);
                                if ($config['y'] != '') {
                                    $tq = Dgd(array(
                                        //'ce' => 1,
                                        'db' => 'd_sevenel',
                                        'tn' => $config['table'],
                                        'cd' => " " . $config['y'] . " = '" . $dbinfo['data'][$key][$zyv['fname']] . "' and  " . $config['conditon'],
                                        'limit' => 1
                                            ));
                                    $dbinfo['data'][$key][$zyv['fname']] = $tq[$config['x']];
                                }
                                break;
                            }
                        case 'combo2': {
                                $tq = Dgd(array(
                                    'db' => 'd_sevenel',
                                    'tn' => 'sort',
                                    'cd' => " id = '" . $dbinfo['data'][$key][$zyv['fname']] . "' ",
                                    'limit' => 1
                                        ));
                                $dbinfo['data'][$key][$zyv['fname']] = $tq['title'];
                                break;
                            }
                        case 'combo3': {
                                $tq = Dgd(array(
                                    'db' => 'd_sevenel',
                                    'tn' => 'sort',
                                    'cd' => " id = '" . $dbinfo['data'][$key][$zyv['fname']] . "' ",
                                    'limit' => 1
                                        ));
                                $dbinfo['data'][$key][$zyv['fname']] = $tq['title'];
                                break;
                            }
                        case 'recommend': {
                                $config = json_decode($zyv['cfg'], true);
                                $bdid_con = $dbinfo['data'][$key]['bdid'] != "" ? "&bdid={$dbinfo['data'][$key]['bdid']}" : '';
                                if ($dbinfo['data'][$key][$zyv['fname']] != 0) {
                                    if ($config['px'] == 1) {
                                        $dbinfo['data'][$key][$zyv['fname']] = "<a href=\"#\" onclick='gxzd(\"" . $dbinfo['data'][$key]['id'] . "\",\"" . $zyv['fname'] . "\",\"0\")' title=\"推荐中！单击取消推荐\"  >  <img src=\"../img/" . $config['paixu'] . "\"></a>    <a href=\"#\"  title=\"排序[order]\"  onclick='tjpx(\"" . $_POST['tid'] . "@" . $_POST['dbname'] . "{$bdid_con}\",\"" . $zyv['fname'] . "\")' >   <img src=\"../img/sucaiwcom8170000bzc.gif\" ait=\"排序[order]\"></a>";
                                    } else {
                                        $dbinfo['data'][$key][$zyv['fname']] = "<a href=\"#\" onclick='gxzd(\"" . $dbinfo['data'][$key]['id'] . "\",\"" . $zyv['fname'] . "\",\"0\")' title=\"推荐中！单击取消推荐\"  >  <img src=\"../img/" . $config['paixu'] . "\"></a>";
                                    }
                                } else {
                                    if ($config['px'] == 1) {
                                        $dbinfo['data'][$key][$zyv['fname']] = "<a href=\"#\" onclick='gxzd(\"" . $dbinfo['data'][$key]['id'] . "\",\"" . $zyv['fname'] . "\",\"1\")'  title=\"未推荐！单击推荐\"  ><img src=\"../img/flag.png\"></a> <a href=\"#\" title=\"排序[order]\"   onclick='tjpx(\"" . $_POST['tid'] . "@" . $_POST['dbname'] . "{$bdid_con}\",\"" . $zyv['fname'] . "\")' >  <img src=\"../img/sucaiwcom8170000bzc.gif\" ait=\"排序[order]\"></a>";
                                    } else {
                                        $dbinfo['data'][$key][$zyv['fname']] = "<a href=\"#\" onclick='gxzd(\"" . $dbinfo['data'][$key]['id'] . "\",\"" . $zyv['fname'] . "\",\"1\")'  title=\"未推荐！单击推荐\"  ><img src=\"../img/flag.png\"></a>";
                                    }
                                }
                                break;
                            }
                    }
                }
            }
            /*
              $_SESSION['as']=$_SESSION['as']+10;
              $dbinfo['as']=$_SESSION['as'];
             */ echo json_encode($dbinfo);
            break;
        }
    case 'width_change': {
            $id = $_POST['id'];
            Du('sevenel', 'fld', array('wd' => $_POST['width']), 'id', $id, 1);
            echo 'ok';
            break;
        }
    case 'items_config_save_ingrid': {
            $field = $_POST['field'];
            $checkbox = array('xr');
            if (in_array($field, $checkbox)) {
                $value = $_POST['value'] == 'true' ? '1' : '0';
            } else {
                $value = $_POST['value'];
            }
            $id = $_POST['id'];
            $save = array($field => $value);
            Du('sevenel', $_POST['table'], $save, 'id', $id, 1);
            ext_request('保存成功[success]');
            break;
        }

    case 'del': {
            $_POST['del'] = 1;
            $_POST['ids'] = json_decode(stripslashes($_POST['ids']));
            if (is_array($_POST['ids'])) {
                foreach ($_POST['ids'] as $id) {
                    Du('sevenel', $_POST['dbname'], $_POST, 'id', $id, 0);
                }
            } else {
                Du('sevenel', $_POST['dbname'], $_POST, 'id', $id, 0);
            }
            $plugin = Plugin::init();
            $plugin->trigger('show1_dd_after', $_POST);
            echo '{success:true,msg:\'ok\'}';
            break;
        }
}
?>